/**
 * Created by Weizehua on 2017/1/21.
 */

import {Crypto} from "../Source/Crypto"

import {assert} from "chai"
import {suite, test} from "mocha-typescript"

@suite
class CryptoTest {
    @test
    async 'Hash for SHA256'(){
        assert.equal('c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646', (await Crypto.hash("1234567890", "SHA256")).toString('hex'));
        assert.notEqual('...', (await Crypto.hash("1234567890", "SHA256")).toString('hex'));
    }

    @test
    async 'Hash for MD5'(){
        assert.equal('e807f1fcf82d132f9bb018ca6738a19f', (await Crypto.hash("1234567890", "md5")).toString('hex'));
        assert.notEqual('...', (await Crypto.hash("1234567890", "md5")).toString('hex'));
    }

    @test
    async 'Hmac-SHA256'() {
        assert.equal('060b3e721245f20040df15b6e78d939bb07b979ef5cd33df2cc062081c0ea767', (await Crypto.hmac("1234567890", "secret", 'SHA256')).toString('hex'));
        assert.notEqual('...', (await Crypto.hash("1234567890", "md5")).toString('hex'));
    }
}
